﻿@using X.PagedList;
@using OA.Model;
@using OA.Core.Helper;
@model PageList<MyDelegation>
@{
    string title = "我的委托";
    ViewBag.Title = title;
    Layout = "~/Areas/Member/Views/Shared/_Layout.cshtml";
    string msg = ViewBag.Msg;
    string tips = string.Empty;
    if (!string.IsNullOrWhiteSpace(msg))
    {
        tips = $"layer.msg('{msg}');";
    }
}
<div class="layui-tab layui-tab-brief" lay-filter="user">
    <div class="layui-form layui-tab-content" id="LAY_ucm">
        <form action="" class="layui-form">
            <div class="layui-form-item">             
                <button type="button" class="layui-btn searchButton" style="display:none;">搜索</button>
                <a class="layui-btn" href="javascript:ShowPage2('/Member/Delegation/Add','添加工作委托','800px','440px')" target="_self">新建工作委托</a>
            </div>
        </form>
    </div>
    <table class="layui-table" lay-data="{url:'GetData', cellMinWidth: 80, page: true,limit:15}" id="resultList" lay-filter="resultList">
        <thead>
            <tr>
                <th lay-data="{field:'ToEmpName', width:100}">受托人</th>
                <th lay-data="{field:'CustomFormName', width:120}">单据</th>
            
                <th lay-data="{field:'StartTime', width:170}">开始时间</th>
                <th lay-data="{field:'EndTime', width:170}">结束时间</th>
                <th lay-data="{field:'CancelDateTime', width:170}">取消时间</th>
                <th lay-data="{field:'StatusName', width:80}">状态</th>
                <th lay-data="{width:80, align:'center', toolbar: '#barDemo'}">操作</th>
            </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">       
        {{# if(d.Status==1){ }}
        <a class="layui-btn layui-btn-xs" href="javascript:Cancel({{d.ID}},'{{d.CustomFormName}}')">取消</a>
        {{# } }}

    </script>
</div> 
<script type="text/javascript">
    function Cancel(currentID,title) {
        layer.confirm('<p>您正在进行工作委托取消操作</p><p style="color:red;">单据名称:' + title + '</p>', {
            title: "删除确认",
            btn: ['是的,我要取消该工作委托', '不小心点错了'] //按钮
        }, function () {
            var url = "/Member/Delegation/Cancel/" + currentID;
            $.getJSON(url, function (data) {
                if (data.State === 200) {
                    layer.msg("工作委托取消成功！");
                    $(".layui-laypage-btn")[0].click();
                }
                else {
                    layer.msg(data.Message);
                }
            });
        }, function () {

        });
       
    }
</script>
